#ifndef __PAINTED_CUBE_BLOCK_H__
#define __PAINTED_CUBE_BLOCK_H__

#include "Block.hpp"
#include "IPaintableBlock.hpp"

using namespace PocketSurvival::Engine;

namespace PocketSurvival
{
    // 完成
    // 染色方块基类，当颜色为 -1 时表示没有颜色，这个跟原本有些许不同。 

    class PaintedCubeBlock : public Block, public IPaintableBlock
    {
    public:
        PaintedCubeBlock();
        virtual void getCreativeValues(std::vector<int32_t> &blockVec) override;
        virtual void getDropValues(int32_t oldValue, int32_t newValue, int32_t toolLevel, std::vector<BlockDropValue> &dropValues) override;
        virtual int32_t getPaintColor(int32_t value) override;
        virtual int32_t paint(int32_t value, int32_t color) override;

        static inline bool IsColored(int32_t data);
        static inline int32_t GetColor(int32_t data);
        static inline int32_t SetColor(int32_t data, int32_t color);
    };

    inline bool PaintedCubeBlock::IsColored(int32_t data)
    {
        return (data & 1) != 0;
    }

    inline int32_t PaintedCubeBlock::GetColor(int32_t data)
    {
        if((data & 1) != 0)
        {
            return (data >> 1) & 0xF;
        }
        return -1;
    }

    inline int32_t PaintedCubeBlock::SetColor(int32_t data, int32_t color)
    {
        if(color != -1)
        {
            return (data & -32) | 1 | (color << 1);
        }
        return data & -32;
    }

} // namespace PocketSurvival

#endif